<template>
  <div style="position: relative">
    <div style="position: sticky;top: 0;z-index: 999;padding-top: 20px;background-color: white;padding-bottom: 20px">
      <div class="table_Header">
        <el-row :gutter="24">
          <el-col :span="type==1?4:2">
            <div class="justify_left">
              <span class="table_HeaderTitle">{{type==1?'订单日期':'创建日期'}}</span>
            </div>
          </el-col>
          <el-col :span="type==1?6:2">
            <div class="align_items">
<!--              <span class="table_HeaderTitle">{{type==1?'商户名称':'开户名'}}</span>-->
              <span class="table_HeaderTitle">{{'商户名称'}}</span>
            </div>
          </el-col>
          <el-col :span="2" v-if="type==2">
            <div class="align_items">
              <span class="table_HeaderTitle">开户名</span>
            </div>
          </el-col>
          <el-col :span="3" v-if="type==2">
            <div class="align_items">
              <span class="table_HeaderTitle">银行账号</span>
            </div>
          </el-col>
          <el-col :span="3" v-if="type==2">
            <div class="align_items">
              <span class="table_HeaderTitle">开户银行</span>
            </div>
          </el-col>
          <el-col :span="4" v-if="type==2">
            <div class="align_items">
              <span class="table_HeaderTitle">备注</span>
            </div>
          </el-col>
          <el-col :span="type==1?6:3">
            <div class="align_items">
              <span class="table_HeaderTitle">{{type==1?'结算日期':'提现金额'}}</span>
            </div>
          </el-col>

          <el-col :span="type==1?4:3">
            <div class="align_items">
              <span style="text-align: center" class="table_HeaderTitle">{{type==1?'结算金额':'余额'}}</span>
            </div>
          </el-col>
          <el-col :span="type==1?4:2">
            <div class="justify_right">
              <span class="table_HeaderTitle">操作</span>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <div class="table_List" v-for="item in orderForm">
      <div class="table_ListHeader">
        <div class="align_items">

        </div>
        <div class="align_items">
        </div>
      </div>
      <div style="padding: 10px">
        <el-row :gutter="24">
          <el-col :span="type==1?4:2">
            <div class="justify_left shop_Height">
              <span style="text-align: left" class="table_ContentTitle" v-if="type==1"> {{item.orderDate | dateFormatter}}</span>
              <span style="text-align: left" class="table_ContentTitle" v-if="type==2"> {{item.createDate |dateFormatter}}</span>
            </div>
          </el-col>
          <el-col :span="type==1?6:2">
            <div class="justify_left shop_Height">
              <span class="table_ContentTitle">{{item.mchName}}</span>
<!--              <span style="margin-top: 5px" v-if="type==2&&item.bankInfoVo" class="table_ContentTitle">{{item.bankInfoVo.bankName}}</span>-->
            </div>
          </el-col>
          <el-col :span="2" v-if="type==2">
            <div class="justify_left shop_Height">
<!--              <span class="table_ContentTitle" v-if="type==1">{{item.mchName}}</span>-->
              <span style="margin-top: 5px" v-if="type==2&&item.bankInfoVo" class="table_ContentTitle">{{item.bankInfoVo.bankName}}</span>
            </div>
          </el-col>
          <el-col :span="3" v-if="type==2">
            <div class="justify_left shop_Height">
              <span class="table_ContentTitle"  v-if="type==2&&item.bankInfoVo">{{item.bankInfoVo.bankNum|bankFilter}}</span>
            </div>
          </el-col>
          <el-col :span="3" v-if="type==2">
            <div class="justify_left shop_Height" >
              <span class="table_ContentTitle" v-if="type==2&&item.bankInfoVo">{{item.bankInfoVo.bank}}</span>
            </div>
          </el-col>
          <el-col :span="4" v-if="type==2">
            <div class="justify_left shop_Height">
              <span class="table_ContentTitle" >{{item.memo}}</span>
            </div>
          </el-col>
          <el-col :span="type==1?6:3">
            <div class="justify_left shop_Height" style="justify-content: center">
              <span class="table_ContentTitle" v-if="item.status==0&&type==1">预计{{item.distributionDate}}结算</span>
              <span class="table_ContentTitle" v-if="item.status==1&&type==1">于{{item.distributionDate}}结算</span>
              <span class="table_ContentTitle" v-if="type==2">{{item.debit}}</span>
            </div>
          </el-col>
          <el-col :span="type==1?4:3">
            <div class="justify_left shop_Height">
              <span class="table_ContentTitle" v-if="type==1">{{item.distributionAmount}}</span>
              <span class="table_ContentTitle" v-if="type==2">{{item.balance}}</span>
            </div>
          </el-col>
          <el-col :span="type==1?4:2">
            <div class="justify_right shop_Height"  v-if="type==1" @click="detailsClick(item.enterpriseId,item.orderDate,type,item.distributionDate)">
              <a class="details_Title">查看详情</a>
            </div>
            <div class="justify_right shop_Height"  v-if="type==2&&item.status==0" @click="detailsClick(item.id,'',type,'')">
              <a class="details_Title">打款</a>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {}
    },
    props: [
      'orderForm','type'
    ],
    methods: {
      detailsClick(id,date,type,distributionDate) {
        this.$emit('detailsClick', id,date,type,distributionDate)
      }
    },
    filters: {
      bankFilter(val){
        var reg = /^(\d{4})\d+(\d{4})$/;
        val = val.replace(reg, "$1 **** **** $2");
        return val
      },
      watchStatus(val) {
        if (val == 0) {
          return '待付款'
        } else if (val == 1) {
          return '已付款'
        } else if (val == 2) {
          return '待退款'
        } else if (val == 3) {
          return '已退款'
        }
      },
      watchDiscount (val) {
        if (val === undefined) {
          return 0
        } else {
          return val
        }
      },
      watchShippingMethod(val){
        if (val == 0) {
          return '普通快递'
        } else if (val == 1) {
          return '到店提货'
        } else if (val == 2) {
          return '同城配送'
        } else {
          return '待发货'
        }
      },
    }
  }
</script>

<style scoped>
  .table_Header {
    width: 100%;
    background-color: #f5f7fa;
    padding: 10px;
  }

  .table_HeaderTitle {
    font-size: 12px;
    color: #353535;
    font-weight: 600;
  }

  .table_List {
    width: 100%;
    margin-bottom: 20px;
    border: 1px solid #f2f2f2;
  }

  .table_ListHeader {
    width: 100%;
    padding: 10px;
    background-color: #f5f7fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .table_ListHeaderTitle {
    font-size: 12px;
    color: #888888;
  }

  .align_items {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .justify_left {
    display: flex;
    align-items: center;
  }

  .justify_right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  .table_ContentTitle {
    font-size: 12px;
    color: #353535;
    width: 100%;
    text-align: center;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .shop_Height {
    min-height: 30px;
  }

  .details_Title {
    font-size: 14px;
    color: #409EFF;
  }
</style>
